package com.gxuwz.leave.service;

import com.gxuwz.leave.dao.DepDao;
import com.gxuwz.leave.entity.Department;

import java.util.List;

public class DepServiceImpl implements DepService{
    private DepDao depDao;
    @Override
    public void addDep(Department entity) {
        depDao.insert(entity);
    }

    @Override
    public Department findDep(String depID) {
        Department dep = new Department();
        dep.setDepID(depID);
        List<Department> deps = depDao.query(dep);
        if(deps==null){
            return dep;
        }else{
            dep = deps.get(0);
        }
        return dep;
    }

    @Override
    public void deleteDep(String depID) {
        depDao.delete(depID);
    }

    @Override
    public List<Department> list(Department entity) {
        return depDao.query(entity);
    }

    @Override
    public void editDep(Department entity) {
        depDao.update(entity);
    }
    public void setDepDao(DepDao depDao) {
        this.depDao = depDao;
    }
}
